<?php
if (! isset($_SESSION)) {
    session_start();
}
include (dirname(dirname(dirname(__FILE__))) . "/zhconfig/Config.php");

$itype=SafeRequest(getPGC("itype"),0);
$moduleid = SafeRequest(getPGC("moduleid"), 0);

$tem_rs=new \ZHMVC\D\Module();
$tem_data=$tem_rs->getOne($moduleid);
$mulu=$tem_data['modulename'];
?>
<html>
  <head>
    <meta charset="utf-8">
      <meta name="renderer" content="webkit|ie-comp|ie-stand">
      <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
      <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
      <meta http-equiv="Cache-Control" content="no-siteapp" />
      <link rel="Bookmark" href="favicon.ico" >
      <link rel="Shortcut Icon" href="favicon.ico" />
      <!--[if lt IE 9]>
      <script type="text/javascript" src="/common/hui/lib/html5.js"></script>
      <script type="text/javascript" src="/common/hui/lib/respond.min.js"></script>
      <![endif]-->
      <link rel="stylesheet" type="text/css" href="/common/hui/static/h-ui/css/H-ui.css" />
      <link rel="stylesheet" type="text/css" href="/common/hui/lib/Hui-iconfont/1.0.9/iconfont.css" />
  </head>
  <body>
  	<?php 
  	//$path=ZH_PATH."/".$mulu."/s/";
  	$path=ZH_PATH."/s/";
  	$pre_path = "";
  	echo "<br>";?>
     <table class="table table-border table-bordered table-bg table-striped">
      <thead>
        <tr class="text-c">
          <th>id</th>
          <th>文件名</th>
          <th>文件大小</th>
          <th>文件类型</th>
          <th>修改时间</th>
        </tr>
      <thead>
      <tbody>
        <?php
        $url_this = "http://".$_SERVER ['HTTP_HOST'].$_SERVER['PHP_SELF'];
        $handle = opendir($path);
        while($file=readdir($handle)){
            if(filetype($path."/".$file)=="file"){
              echo "<tr class=\"text-c\">";
              if(filetype($path."/".$file)=="file"){
                  if(pathinfo($path."/".$file, PATHINFO_EXTENSION )=="php")
                  {
                      echo "<td><input type=\"radio\" name=\"phpfile\" value=\"".pathinfo($path."/".$file, PATHINFO_BASENAME)."\" checked=\"checked\" /></td>";
                  }
                  else 
                  {
                      echo "<td> </td>";
                  }
              }
              else 
              {
                  echo "<td> </td>";
              }
              echo "<td>".$file."</td>";
              echo "<td>".filesize($path."/".$file)."</td>";
              if(filetype($path."/".$file)=="dir"){
                $next = $pre_path."/".$file;
                echo "<td><a href=\"$url_this?path=$next\">目录</a></td>";
              }else{
                echo "<td>".filetype($path."/".$file)."</td>";
              }
              echo "<td>".date("Y年n月t日",filemtime($path."/".$file))."</td>";
              echo "</tr>";
            }
        }
        closedir($handle);
        ?>
      </tbody>
      <tfoot>
      	<tr>
      		<td colspan="5" class="text-c va-m"><a href="javascript:;" onclick="chooseReason()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 添加</a></td>
      	</tr>
      </tfoot>
    </table>
<script type="text/javascript" src="/common/hui/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
function chooseReason() 
{
	var phpfile=$("input[name='phpfile']:checked").val();
	//alert(aid)
    window.opener.document.getElementById("<?php echo $itype;?>").value = phpfile;
    window.close();
}
</script>
  </body>
</body>
